package com.medical.data.vo;


import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.medical.data.exception.MyException;
import com.medical.data.utils.DateUtil;
import com.medical.data.utils.ResultCode;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class ProjectVo {

    @ApiModelProperty(value = "用户名称")
    private String userId;

    @NotBlank(message = "项目名称不可为空")
    @ApiModelProperty(value = "项目名称")
    private String name;

    @NotBlank(message = "研究领域不可为空")
    @ApiModelProperty(value = "研究领域")
    private String area;

    @NotBlank(message = "项目描述不可为空")
    @ApiModelProperty(value = "描述")
    private String description;

    @NotNull
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "项目开始时间")
    private Date beginTime;

    @NotNull
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @ApiModelProperty(value = "项目结束时间")
    private Date endTime;

    @NotBlank(message = "发起单位不可为空")
    @ApiModelProperty(value = "发起单位")
    @TableField("Initiator")
    private String initiator;

    @NotNull
    @ApiModelProperty(value = "1为可共享的项目")
    private Boolean isShare;

//    public void setEndTime(Date endTime) {
//        if (!DateUtil.compareDateAndTime(endTime,this.beginTime)){
//            throw new MyException(ResultCode.ERROR.getCode(),"项目结束时间不能小于项目开始时间");
//        }
//        this.endTime = endTime;
//    }
}
